<?php
require_once __DIR__ .  '/../ZendPartial.php';

class ZendPartial_TextareaController extends ZendPartialController
{
    /** テンプレートファイル名 */
    const NAME_TEMPLATE = 'textarea.tpl';

    /** ネーム */
    public $NAME;
    /** バリュー */
    public $VALUE;
    /** イベントプロパティ */
    public $ON_EVENT;
    /** スタイルプロパティ */
    public $STYLE;

    public function __construct($Name, $Rows, $Cols, $TemplateDir='')
    {
        if ($TemplateDir == ''){
            $TemplateDir = __DIR__;
        }
        parent::__construct($TemplateDir);
        $this->NAME = $Name;
        $this->view->ROWS = $Rows;
        $this->view->COLS = $Cols;
        $this->VALUE = '';
    }

    /**
     * フェッチ
     * @see ZendPartialController::fetch()
     * @return string
     */
    public function fetch($TemplateFileName='')
    {
        if ($TemplateFileName == ''){
            $TemplateFileName = self::NAME_TEMPLATE;
        }
        $this->view->NAME = $this->NAME;
        $this->view->ATTRIBUTE = $this->getAttribute();
        $this->_setValueFromRequest();
        $sHtml = parent::fetch($TemplateFileName);
        return $sHtml;
    }

    protected function _setValueFromRequest()
    {
        if ($this->VALUE != '') {
            $this->view->VALUE = $this->VALUE;
            return;
        }
        if (isset($_REQUEST[$this->NAME])){
            $this->view->VALUE = $_REQUEST[$this->NAME];
        }
    }
}
